﻿@model SuperiorModel.OrderDetailModel
@{
    ViewBag.Title = "商品详情";
    Layout = "~/Views/Shared/_Layout.cshtml";
   
}
<input type="hidden" id="mapRotute" map="map_order" />

<style>
    .layui-content {
        width: 98%;
        margin: auto;
        text-align: center;
    }

    .layui-table-cell {
        text-align: center;
    }

    .layui-input-w120 {
        width: 110px;
    }

    .layui-row {
        margin-left: 20px;
    }

    .layui-card {
        margin-bottom: 5px;
        border: 1px solid #ccc;
        border-radius: 5px;
    }

    .layui-card-body {
    }

    .layui-form {
        margin-bottom: 0px;
    }

    .layui-form-item {
        margin-bottom: 5px;
    }

    .layui-badge {
        margin-left: 10px;
    }
</style>

<div class="title_ding">

    <p id="location">
        当前位置：
        订单详情
    </p>
</div>
<div class="layui">
    <div class="shopmain">
        <div class="container">
            <div class="layui-main" style="padding: 0px;width: 1100px">
                <div class="layui-card" style="margin-top:10px;">
                    <div class="layui-card-header">收货信息</div>
                    <div class="layui-card-body">
                        <div class="layui-form-item">
                            <div class="layui-row">
                                <div class="layui-col-md8">
                                    收货人：@Model.ConsigneeName
                                </div>
                                <div class="layui-col-md4">
                                    手机号：@Model.ConsigneePhone
                                </div>
                            </div>

                        </div>
                        <div class="layui-form-item">
                            <div class="layui-row">
                                <div class="layui-col-md8">
                                    收货地址：@Model.Address
                                </div>
                                <div class="layui-col-md4">
                                    邮编：@Model.ZipCode
                                </div>
                            </div>
                        </div>
                    </div>

                </div>
                <div class="layui-card">
                    <div class="layui-card-header">
                        订单编号：
                        <span>@Model.OrderNo</span>
                        <span class="layui-badge layui-bg-gray">
                            @switch (Model.OrderStatus)
                            {
                                case 0:
                                    @Html.Raw("待支付");
                                    break;
                                case 1:
                                    @Html.Raw("订单成功(已发货)");
                                    break;
                                case 2:
                                    @Html.Raw("订单失败");
                                    break;
                                case 3:
                                    @Html.Raw("已付款(待发货)");
                                    break;
                                case 4:
                                    @Html.Raw("申请售后");
                                    break;
                            }
                        </span>
                        @switch (Model.OrderStatus)
                        {
                            case 2:
                               <span class="layui-badge layui-bg-gray">@Model.FailReason</span>
                                break;
                            case 4:
                                <span class="layui-badge layui-bg-gray">@(Model.ServiceStatus==1?"已处理":"未处理")</span>
                                break;
                        }
                        <div class="layui-input-block" style="margin:0;float:right;">
                        </div>

                    </div>
                    <div class="layui-card-body" style="padding:0px  15px 5px 15px">
                        <table class="layui-hide" id="table1"></table>
                        <div class="layui-form layui-border-box layui-table-view" lay-filter="LAY-table-1" style="">
                            <div class="layui-table-box">
                                <div class="layui-table-header">
                                    <table class="layui-table" cellspacing="0" cellpadding="0" border="0">
                                        <thead>
                                            <tr>
                                                <th data-field="TypeID">
                                                    <div class="layui-table-cell laytable-cell-1">
                                                        <span>商品</span>
                                                    </div>
                                                </th>
                                                <th data-field="ProductName">
                                                    <div class="layui-table-cell laytable-cell-1">
                                                        <span>规格</span>
                                                    </div>
                                                </th>
                                                <th data-field="ProductName">
                                                    <div class="layui-table-cell laytable-cell-1">
                                                        <span>单价</span>
                                                    </div>
                                                </th>
                                                <th data-field="SalePrice">
                                                    <div class="layui-table-cell laytable-cell-1">
                                                        <span>数量</span>
                                                    </div>
                                                </th>
                                                <th data-field="ProductNum">
                                                    <div class="layui-table-cell laytable-cell-1">
                                                        <span>商品编码</span>
                                                    </div>
                                                </th>
                                            </tr>
                                        </thead>
                                    </table>
                                </div>
                                <div class="layui-table-body layui-table-main">
                                    <table class="layui-table" cellspacing="0" cellpadding="0" border="0">
                                        <tbody>
                                            @foreach (var item in Model.OrderItems)
                                            {
                                                <tr data-index="0" class="">
                                                    <td data-field="" data-content="1">
                                                        <div class="layui-table-cell laytable-cell-1">@item.ProductName</div>
                                                    </td>
                                                    <td data-field="">
                                                        <div class="layui-table-cell laytable-cell-1">@item.ProppetyCombineName</div>
                                                    </td>
                                                    <td data-field="" data-content="">
                                                        <div class="layui-table-cell laytable-cell-1">@item.SalePrice</div>
                                                    </td>
                                                    <td data-field="" data-content="">
                                                        <div class="layui-table-cell laytable-cell-1">@item.BuyNum</div>
                                                    </td>
                                                    <td data-field="">
                                                        <div class="layui-table-cell laytable-cell-1">@item.SkuCode</div>
                                                    </td>
                                                </tr>
                                            }
                                           
                                        </tbody>
                                    </table>
                                </div>
                            </div>
                            <style>
                                .laytable-cell-1 {
                                    width: 200px;
                                }
                            </style>
                        </div>
                        <div class="layui-form">
                            <div class="layui-form-item">
                                <div class="layui-row" style="margin-top:10px;">
                                    <div class="layui-col-md4">
                                        商品金额：@(Model.OrderAmount)元
                                    </div>
                                   
                                    <div class="layui-col-md4">
                                        运费：@(Model.ShippingAmount)元
                                    </div>
                                    <div class="layui-col-md4">
                                        实收金额：@(Model.RealityAmount)元
                                    </div>
                                </div>

                            </div>
                            <div class="layui-form-item">
                                <div class="layui-row" style="margin-top:10px;">
                                    <div class="layui-col-md4">
                                        是否使用优惠券：@(Model.CouponId>0?"是":"否")
                                    </div>

                                    <div class="layui-col-md4">
                                        优惠券名称：@Model.CouponName
                                    </div>
                                    <div class="layui-col-md4">
                                        优惠券抵消金额：@(Model.CouponDelAmount)元
                                    </div>
                                </div>

                            </div>

                            <div class="layui-form-item">
                                <div class="layui-row">
                                    <div class="layui-col-md4">
                                        发货状态：
                                        <span class="layui-badge layui-bg-green">@(Model.SendStatus==1?"已发货":"未发货")</span>
                                        @if (Model.OrderStatus == 1)
                                        {
                                            <span class="layui-badge layui-bg-gray" style="margin-left:5px;">发货时间: @Model.SendTime</span>
                                            
                                        }
                                        else if (Model.OrderStatus == 3)
                                        {
                                            @Html.Raw("请返回列表发货");
                                        }


                                    </div>
                                    <div class="layui-col-md4">
                                        支付编码：@Model.PayOderNo
                                    </div>
                                    <div class="layui-col-md4">
                                        支付时间：@Model.PayTime
                                    </div>
                                </div>
                            </div>
                            @if (Model.SendStatus == 1)
                            {
                                <div class="layui-form-item">

                                    <div class="layui-row" style="margin-top:10px;">
                                        <div class="layui-col-md4">
                                            快递名称：@Model.DeliveryName
                                        </div>

                                        <div class="layui-col-md4">
                                            快递单号：@Model.DeliveryNo
                                        </div>
                                        <a class="layui-btn layui-btn-normal layui-btn-xs layui-btn-mini editDelivery" href="javascript:void(0);" OptionId="@Model.Id" DeliveryName="@Model.DeliveryName" DeliveryNo="@Model.DeliveryNo">修改快递信息</a>
                                    </div>
                                </div>
                            }
                          
                            <div class="layui-form-item">

                                <div class="layui-row">
                                    备注信息：@Model.Remark
                                </div>
                            </div>
                            <div class="layui-form-item">

                                <div class="layui-row">
                                    下单时间：@Model.CreateTime
                                </div>
                            </div>
                        </div>
                    </div>
                <div class="layui-card" style="margin-bottom:20px;">
                    <div class="layui-card-header">其他信息</div>
                    <div class="layui-card-body" style="padding-left:15px;padding-right:15px;">
                        <form class="layui-form">
                            <div class="layui-form-item">
                                <div class="layui-row">
                                    @*<div class="layui-col-md4">
                                        推荐人：闫利华
                                    </div>
                                    <div class="layui-col-md4">
                                        手机号：18910837821
                                    </div>
                                    <div class="layui-col-md4">
                                        应返积分：10
                                    </div>*@
                                </div>
                                <br>
                            </div>
                        </form>
                    </div>
                </div>
            </div>
            
        </div>
    </div>
</div>
</div>
<script>
    var _orderid = "";
    layui.use('form', function () {
        var form = layui.form;
        form.render();
        form.on('submit(btn_submit)', Submit);//确认发货
    });

    function Submit() {
        var deliveryName = $("#text_deliveryName").val();
        var deliveryNo = $("#text_deliveryNo").val();
        var model = {};
        model.Id = _orderid,
        model.DeliveryName = deliveryName;
        model.DeliveryNo = deliveryNo;
        var index = layer.load(1);
        RequestManager.Ajax.Post("/Order/UpdateDelivery", model, true, function (data) {
            layer.close(index);
            if (data.IsSuccess) {
                layer.alert("修改成功", function () {
                    window.location.reload();
                })
            } else {
                layer.alert(data.Message);
            }
        })
    }

    $(document).on('click', '.editDelivery', function () {
        _orderid = $(this).attr("OptionId");
        var deliveryName = $(this).attr("DeliveryName");
        var deliveryNo = $(this).attr("DeliveryNo");
        layer.open({
            type: 1,
            skin: 'layui-layer-rim', //加上边框
            area: ['420px', '300px'], //宽高
            content: CreateHtml(deliveryName,deliveryNo)
        });
            
        
    })

    function CreateHtml(deliveryName, deliveryNo) {
        var arr = [];
        arr.push('<div class="layui-form" action="" >');
        arr.push('<div class="layui-form-item">');
        arr.push('<label for="text_deliveryName" class="layui-form-label">快递名称</label>');
        arr.push('<div class="layui-input-inline" style="width:50%">');
        arr.push('<input type="text" id="text_deliveryName" name="text_deliveryName" lay-verify="required" class="layui-input" value="'+deliveryName+'" placeholder="请输快递名称">');
        arr.push('</div>');
        arr.push(' <div class="layui-form-mid layui-word-aux"><span class="x-red">*</span></div>');
        arr.push('</div>');

        arr.push('<div class="layui-form-item">');
        arr.push(' <label for="text_deliveryNo" class="layui-form-label">快递单号</label>');
        arr.push('<div class="layui-input-inline" style="width:50%">');
        arr.push(' <input type="text" id="text_deliveryNo" name="text_deliveryNo" lay-verify="required"  class="layui-input" value="'+deliveryNo+'" placeholder="请输快递单号">');
        arr.push('</div>');
        arr.push(' <div class="layui-form-mid layui-word-aux"><span class="x-red">*</span></div>');
        arr.push('</div>');
        arr.push('<div class="layui-form-item" style="text-align:center;">');
        arr.push('<div class="layui-input-block" style="margin:0;"><button class="layui-btn" lay-submit lay-filter="btn_submit">确定</button></div>');
        arr.push('</div>');
        arr.push('</div>');
        return arr.join('');
    }
</script>
